﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ShevaEngine.Core.Modules.ArtificialIntelligence.Pathfinding
{
    /// <summary>
    /// Navigation graph node record.
    /// </summary>
    public class NavigationGraphNodeRecord
    {
        /// <summary>Navigation graph node.</summary>
        public NavigationGraphNode Node;
        /// <summary>Cost so far.</summary>
        public float CostSoFar;
        /// <summary>Estimated total cost.</summary>
        public float EstimatedTotalCost;
        /// <summary>Connection.</summary>
        public NavigationGraphConnection Connection;

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="costSoFar"></param>
        /// <param name="estimatedTotalCost"></param>
        public NavigationGraphNodeRecord(NavigationGraphNode node, NavigationGraphConnection connection = null,
            float costSoFar = 0.0f, float estimatedTotalCost = float.MaxValue)
        {
            this.Node = node;
            this.Connection = connection;
            this.CostSoFar = costSoFar;
            this.EstimatedTotalCost = estimatedTotalCost;
        }
    }

    /// <summary>
    /// Navigation graph node record equality comparer.
    /// </summary>
    public class NavigationGraphNodeRecordEqualityComparer : IEqualityComparer<NavigationGraphNodeRecord>
    {
        /// <summary>Singleton.</summary>
        public static readonly NavigationGraphNodeRecordEqualityComparer Instance = new NavigationGraphNodeRecordEqualityComparer();

        /// <summary>
        /// Method compares two navigation graph node records.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public bool Equals(NavigationGraphNodeRecord x, NavigationGraphNodeRecord y)
        {
            return x.Node == y.Node;
        }

        /// <summary>
        /// Get hash code.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int GetHashCode(NavigationGraphNodeRecord obj)
        {
            return base.GetHashCode();
        }
    }
}
